package com.waar.kickball.model;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * @author Craig McIlwee
 * Copyright Lance + Craig 2013
 */
@Entity
@Table(name = "team")
public class Team extends KickballEntity {

	private String name;
	@OneToOne(optional = false)
	@JoinColumn(name = "captain_id", nullable = false)
	private Player captain;
	@ManyToMany
	private Set<Player> players;
	
	Team() { }
	
	/**
	 * @param name of the team
	 * @param captain of the team
	 * @param players that are on the team
	 */
	public Team(String name, Player captain, Set<Player> players) {
		this.name = name;
		this.captain = captain;
		this.players = players;
	}
	
	/**
	 * @return the name of the team
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @return the captain
	 */
	public Player getCaptain() {
		return captain;
	}
	
	/**
	 * @return all players on the team
	 */
	public Set<Player> getPlayers() {
		return players;
	}
	
}
